using Xunit;
using Xunit.Abstractions;

namespace graver.test;

public class CommonTest
{
    private static readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();

    [Fact(DisplayName = "TestCommon")]
    public void TestCommon()
    {
        var line = "1 + 2 * 3";
        var lexer = new Lexer(line);
        while (true)
        {
            var token = lexer.NextToken();
            if (SyntaxKind.EndOfFileToken == token.Kind)
            {
                break;
            }
            if (SyntaxKind.BadToken == token.Kind)
            {
                log.Error($"lexer has error, bad token:{token.Text}");
                break;
            }
            var msg = $"{token.Kind}: '{token.Text}'";
            if (null != token.Value)
            {
                msg += $" {token.Value}";
            }
            log.Info(msg);
        }
    }
}